<html>
<head>
    <title>code</title>
</head>
<script src="js/qrcode.js"></script>
<script src="js/jquery-3.3.1.js"></script>
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
<script type="text/javascript">
    var localIp=returnCitySN["cip"];
    document.write(localIp);

    console.log("ip is:"+localIp);

</script>
<style>
    #box{
        position: absolute;
        top: 50%;
        left: 50%;
    }
    #qrcode{
        margin-left: -100px;
        margin-top: -100px;
    }
</style>
<body>

<div id="box">
    <div id="qrcode"></div>
</div>
<script>
    // var localIp=returnCitySN["cip"];
    // console.log("aaa:"+localIp);
    var qrcode = new QRCode(document.getElementById("qrcode"), {
        text: "http://"+localIp+":8080/DiaoSi_war_exploded/",
        width: 200,
        height: 200,
        colorDark : "#000000",
        colorLight : "#ffffff",
        correctLevel : QRCode.CorrectLevel.H
    });

    //获取本机的网络ip地址
    function jsonpCallback(res) {
        var ip = res.Ip;    // ip地址
        var aa = res.Isp.split("市");
        var isp = aa[0];    // ip省份
        alert(ip);
    }

    function getIntnetIP() {
        var JSONP=document.createElement("script");
        JSONP.type="text/javascript";
        JSONP.src="http://chaxun.1616.net/s.php?type=ip&v=&output=json&callback=jsonpCallback";
        document.getElementsByTagName("head")[0].appendChild(JSONP);
    }
    getIntnetIP();
</script>
</body>
</html>
